new Vue({
  el: '#app',
  data() {
    return {
      form: {
        serachKey: "",
        page: 1,			//页数
        limit: 10			//每页数据条数
      },
      formData: {},
      tableData: [{
        Enterprise_Name: '哆啦A梦',  //企业名称 
        Enterprise_Address: '黑龙江省哈尔滨市',  //企业地址
        Enterprise_ID: '7456851648',   //企业编号
        Contact_Name: '胖虎',   //联系人姓名
        Contact_Phone: 18456523125  //联系人电话
      }],		//表格数据
      total: 1,
      dialogForm: false,
      title: '',
      multipleSelection: []
    }
  },
  mounted() {
    // this.getList()
  },
  methods: {
    onSerach() {				//查询方法
      console.log("搜搜")
    },
    addContract() {
      console.log("跳转")
    },
    getList() {     //换页方法
      let _this = this
      $.ajax({
        type: 'POST',
        data: {
          Row_Status: '2',
          token: $.cookie("token")
        },
        url: DomainName + '/getSalesUnitPriceAction',
        success: function (data) {
          _this.tableData = data;
          console.log(data)
        },
        complete: function (XMLHttpRequest) {
          _this.loading = false
          if (XMLHttpRequest.getResponseHeader("REDIRECT") == "REDIRECT") {
            window.parent.document.location.href = "../../../../" + XMLHttpRequest.getResponseHeader("CONTENTPATH");
          }
        },
        dataType: "json"
      });
    },
    addEnterprise() {
      window.location.href = './Add.html'
    },
    showMember(EnterpriseInfo_SerialNumber) {
      sessionStorage.setItem("EnterpriseInfo_SerialNumber", EnterpriseInfo_SerialNumber)
      window.location.href = './show.html?EnterpriseInfo_SerialNumber=' + EnterpriseInfo_SerialNumber
    },
    editMember(EnterpriseInfo_SerialNumber) {
      console.log(EnterpriseInfo_SerialNumber)
      sessionStorage.setItem("EnterpriseInfo_SerialNumber", EnterpriseInfo_SerialNumber)
      let _this = this
      let detel = {};
      $.ajax({
        url: DomainName + '/getSalesUnitOriginal',
        type: 'POST',
        data: { Sales_Unit_Price_SerialNumber: EnterpriseInfo_SerialNumber, token: $.cookie("token") },
        success: function (res) {
          if (res.length == 1) {
            console.log(res)
            res[0].Row_Status = '0'
            detel = res[0];
            let data = {
              Data: JSON.stringify({ Modify: { sales_unitprice: [detel] } }),
              token: $.cookie("token")
            };
            $.ajax({
              url: DomainName + '/getEditAction',
              type: 'POST',
              data,
              success: function (res) {
                if (res.Status === 'success') {
                  _this.$message.success("已同意");
                  _this.getList();
                } else {
                  _this.$message.error("操作失败，请稍后再试")
                }
              },
              error: function () {
                _this.$message.error("操作失败，请稍后再试")
              },
              complete: function (XMLHttpRequest) {
                _this.loading = false
                if (XMLHttpRequest.getResponseHeader("REDIRECT") == "REDIRECT") {
                  window.parent.document.location.href = "../../../../" + XMLHttpRequest.getResponseHeader("CONTENTPATH");
                }
              }
            })
          }
        },
        complete: function (XMLHttpRequest) {
          _this.loading = false
          if (XMLHttpRequest.getResponseHeader("REDIRECT") == "REDIRECT") {
            window.parent.document.location.href = "../../../../" + XMLHttpRequest.getResponseHeader("CONTENTPATH");
          }
        }
      })
    },
    deletMember(EnterpriseInfo_SerialNumber) {
      this.$prompt('请输入拒绝原因，如线下沟通则说明', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        inputPattern: /^(?!\s*$).+/,
        inputErrorMessage: '原因不能由零个或多个空格组成',
        type: 'warning',
      }).then(({ value }) => {
        let _this = this
        let detel = {};
        $.ajax({
          url: DomainName + '/getSalesUnitOriginal',
          type: 'POST',
          data: { Sales_Unit_Price_SerialNumber: EnterpriseInfo_SerialNumber, token: $.cookie("token") },
          success: function (res) {
            if (res.length == 1) {
              console.log(res)
              res[0].Row_Status = '1'
              detel = res[0];
              let data = {
                Data: JSON.stringify({ Modify: { sales_unitprice: [detel] } }),
                token: $.cookie("token")
              };
              $.ajax({
                url: DomainName + '/getEditAction',
                type: 'POST',
                data,
                success: function (res) {
                  if (res.Status === 'success') {
                    // _this.$message.success("已同意");
                    _this.getList();
                  } else {
                    _this.$message.error("操作失败，请稍后再试")
                  }
                },
                error: function () {
                  _this.$message.error("操作失败，请稍后再试")
                },
                complete: function (XMLHttpRequest) {
                  _this.loading = false
                  if (XMLHttpRequest.getResponseHeader("REDIRECT") == "REDIRECT") {
                    window.parent.document.location.href = "../../../../" + XMLHttpRequest.getResponseHeader("CONTENTPATH");
                  }
                }
              })
            }
          },
          complete: function (XMLHttpRequest) {
            _this.loading = false
            if (XMLHttpRequest.getResponseHeader("REDIRECT") == "REDIRECT") {
              window.parent.document.location.href = "../../../../" + XMLHttpRequest.getResponseHeader("CONTENTPATH");
            }
          }
        })
        this.getList();
        this.$message({
          type: 'success',
          message: '拒绝成功!'
        });
      }).catch(() => {
        this.$message({
          type: 'info',
          message: '已取消'
        });
      });
    },
    expandChange(row, expandedRows) {
      let _this = this
      console.log(expandedRows);
      // if (expandedRows.length) {
      //   expandedRows[expandedRows.length - 1].Children = _this.tableData2.filter(item => {
      //     return item.Sales_Order_SerialNumber == row.Sales_Order_SerialNumber
      //   })
      // } else {
      //   _this.Children = []
      // }
    },
  },
})